#pragma once
#include "gtest/gtest.h"
#include "Utility/FileSystem/SGFileSystem.h"
#include "../Interface/BeamSectionNumericalCalculatorFactory.h"
#include "../I1SectionNumericalCalculator.h"
#include "../SectionCalculator/writeVtk.h"

using SG::DataStructure::FEM::BeamSectionStandardTypes;
using SG::DataStructure::FEM::PBARLData;
using SG::FEMSolver::Element::BeamSectionNumericalCalculatorFactory;
using SG::FEMSolver::Element::I1SectionNumericalCalculator;

// 将 BeamSectionNumericalCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BeamSectionNumericalCalculatorFactoryTest, I1SectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BeamSectionNumericalCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_I1);
    auto I1CalculatorPtr = dynamic_cast<I1SectionNumericalCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != I1CalculatorPtr);
}

// I1 截面网格划分测试
TEST (BeamSectionNumericalMeshTest, I1Section)
{
    // Input data
    PBARLData section;
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_I1);
    section.m_dimension = {4.0, 3.0, 6.0, 8.0};
    int refineLevel{0};

    // Test data
    Meshes meshes;
    I1SectionNumericalCalculator I1SecMehser;
    I1SecMehser.Mesh (section, _OUT meshes, refineLevel);
    std::string filename = "I1BeamSectionMesh";
    std::string discription = "I1-Type Beam Section Mesh";
    SG::FEMSolver::Element::writeVtk (meshes, filename, discription);
    auto fileTest = SG::Utility::FileSystem::getFullPath (filename + ".vtk");

    // Target data
    auto fileTarget = SG::Utility::FileSystem::getTestDataPath ("SGFem/BeamSecPropCalculator/" + filename + "Target.vtk");

    // Check
    ASSERT_TRUE (SG::Utility::FileSystem::compareVTK (fileTarget, fileTest));
}